<?php
	require '../../config/config.php';
	$ConfigSql="select * from config where id='1'";
	$ConfigInfo=mysqli_query($con,$ConfigSql);
	$ConnfigRs=mysqli_fetch_array($ConfigInfo);
	session_start();
	if(empty($_SESSION['member'])){
	    echo "<script>location='../../../index.php';</script>";
	    exit;
	}
	if($_GET['ops']=="logout"){
	    $_SESSION['member']="";
	    session_destroy();
	    echo "<script>alert('您已退出登录！');location='../../index.php';</script>";
	}
	if($_POST){
		$pwd=$_POST['pwd'];
		if(empty($pwd)){
			echo "<script>alert('密码不能为空！');location='./index.php';</script>";
		}else{
			$sql="select * from member where user='".$_SESSION['member']."'";
			$rs=mysqli_fetch_array(mysqli_query($con,$sql));
			if($rs['password']!=MD5($pwd)){
			    echo "<script>alert('密码输入错误，请重试！');location='./index.php';</script>";
			}else{
			    if($rs['type']=="1"){
			        echo "<script>alert('账号注销失败，请在注销前联系管理员解除您的职位！');location='../my.php';</script>";
			    }else{
			        mysqli_query($con,"UPDATE `member` SET `password` = '',`email` = '',`state` = '-1' WHERE `member`.`user` = '".$_SESSION['member']."'");
    			    $_SESSION['member']="";
    			    echo "<script>alert('账号注销成功，此账号将永久被停用！');location='../../index.php';</script>";
			    }
			}
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php echo $ConnfigRs['name'];?>-密码修改</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../css/head.css"/>
  <link rel="stylesheet" href="../../layui/css/layui.css">

<link rel="stylesheet" href="../../css/global.css">

<script src="../../layui/layui.js"></script>
</head>
<body >

<div class="dvhead">
	<div class="dvlogo"><a href="../../../../index.php">校园服务反馈系统</a></div>
	<div class="dvreg">
		<?php
		    if(empty($_SESSION['member'])){
                echo "已有账号，立即&nbsp;<a href='login.php'>登录</a>";
            }else{
                echo "欢迎您，".$_SESSION['member']." &nbsp;&nbsp;<a href='?ops=logout'> 退出</a>";
            }
		?>
	</div>
</div>

<div class="main layui-clear">
  <div class="fly-panel" pad20>
    <div class="layui-form layui-form-pane">
        <br />&nbsp;&nbsp;&nbsp;<a href="../my.php">个人中心</a> / 注销账号
		<form method="post">
			<table class="news-edit">
				<tr>
					<th>账&nbsp;&nbsp;&nbsp;号：</th>
					<td><?php echo $_SESSION['member'];?></td>
				</tr>
				<tr>
					<th>注&nbsp;&nbsp;&nbsp;意：</th>
					<td><font color="red">注销账号后，您的账号将会被停用，个人信息将被永久删除且不可恢复。我们将保留但不仅限于您发布的内容。此账号的用户名不可再次用于注册！</font></td>
				</tr>
				<tr>
					<th>密&nbsp;&nbsp;&nbsp;码：</th>
					<td><input type="password" name="pwd" placeholder="请输入密码" class="layui-input"/></td>
				</tr>
				<tr>
					<th></th>
					<td><input type="submit" value="提交修改" class="layui-btn" /></td>
				</tr>
			</table>
		</form>
    </div>
  </div>
</div>

 <script type="text/javascript" charset="utf-8" src="js/kindeditor.js"></script>
  <script type="text/javascript">
    KE.show({
        id : 'content',
		resizeMode : 1,
        cssPath : './index.css',
        items : [
        'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
        'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
        'insertunorderedlist', 'emoticons', 'image', 'link']
    });
  </script>
<script>

layui.cache.page = '';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "2.0.0"
  ,base: '../res/mods/'
}).extend({
  fly: 'index'
}).use('fly');
</script>
</body>
</html>